<?php
namespace app\api\validate;

use think\Validate;

class MemberValidate extends Validate
{
    protected $rule = [
        "email"=>'require|email|unique:Member',
        "verify_id" => 'require',
        "password" => 'require|alphaNum',
        "code"=>"require"
    ];

    protected $message = [
        'email.require' => '邮箱必须填写',
        "verify_id.require"=>"验证id缺失",
        "email.email"=>"邮箱格式错误",
        "email.unique" => "邮箱已被占用请重新注册",
        "password.require" => "密码必须填写",
        "password.alphaNum" => "密码必须由数字和字母组成",
        "code.require"=>"验证码必须填写"
    ];

    protected $scene = [
        'register' => ['email','passwd'],
        'send-email' => ['email','verify_id','code'],
        'login' => ['email','passwd'],
    ];

    // edit 验证场景定义
    public function sceneLogin()
    {
        return $this->only(['email','password'])
            ->append('email', 'require')
            ->remove('email', 'unique')
            ->append('password', 'require');
    }
}